﻿using System;
using NUnit.Framework;
using Microsoft.Practices.Unity;
using Rhino.Mocks;

namespace WebCrawler.Tests
{
    public class UrlRepositoryTestData : CrawlerTestData
    {
        public UrlRepositoryTestData(string startUrl)
            : base(startUrl)
        {
        }
    }

    public class UrlRepositoryTests : CrawlerTestFixture<UrlRepositoryTestData>
    {
        [SetUp]
        public new void Setup()
        {
            Data = new UrlRepositoryTestData("http://company.com");
            //setup stubs
        }
       
       [Test] public void Match_ShouldRecognizeUrls()
       {
           var repository = new UrlRepository();
           Assert.IsFalse(repository.Contains(Data.Url1));
           Assert.IsTrue(repository.AddNew(Data.Url1));
           Assert.IsTrue(repository.Contains(Data.Url1));
           Assert.IsFalse(repository.Contains(Data.Url2));
       } 

       [Test] public void ShouldDetectPreviouslyAddedUrls()
       {
           var repository = new UrlRepository();
           Assert.IsTrue(repository.AddNew(Data.Url1));
           Assert.IsFalse(repository.AddNew(Data.Url1));
       }
    }
}